#include "widget.h"
#include "ui_widget.h"


Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    myp = new QPushButton(this);
    myp->setText("hello world");

    connect(myp, &QPushButton::clicked, this, &Widget::handleClick);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handleClick()
{
    // 当按钮被点击时，就把按钮的内容进行替换
    if(myp->text() == QString("hello world"))
    {
        myp->setText("hello qt");
    }else {
        myp->setText("hello world");
    }
}

